import { LandlordEntity } from "@/entities/LandlordEntity";
import request from "../request";
import BusinessConstant from "@/constant/BusinessConstant";
// 路径前缀
const PREFIX = BusinessConstant.ROOT_SERVER + "/landlord";

export default class LandlordApi {
  /**
   * 登录
   * @param phone 手机号
   * @param password 密码
   */
  static login(phone: string, password: string) {
    return request({
      method: "POST",
      url: `${PREFIX}/login`,
      data: {
        phone,
        password,
      },
    });
  }

  /**
   * 注册
   * @param phone 手机
   * @param password 密码
   */
  static registry(phone: string, password: string) {
    return request({
      method: "POST",
      url: `${PREFIX}/registry`,
      data: {
        phone,
        password,
      },
    });
  }

  /**
   * 获取房东信息
   */
  static getLandlord() {
    return request({
      method: "GET",
      url: `${PREFIX}`,
    });
  }

  /**
   * 更新房东信息
   * @param data 需要更新的数据
   */
  static updateLandlord(
    data:
      | { name?: string; remark?: string }
      | LandlordEntity.ILandlordVerification
  ) {
    return request({
      method: "PUT",
      url: `${PREFIX}`,
      data,
    });
  }

  /**
   * 通过id列表获取房东信息列表
   * @param ids
   */
  static getLandlordByIds(ids: string) {
    return request({
      method: "GET",
      url: `${PREFIX}/list?ids=${ids}`,
    });
  }

  /**
   * 通过房东id获取租客信息
   */
  static getTenantsByLandlordId() {
    return request({
      method: "GET",
      url: `${PREFIX}/tenant`,
    });
  }
}
